import { PriceShowTypeEnum } from "@/enums/activityEnum";
import { formatToFixed } from "@/utils/number";

export const getPriceObject = (
    priceShowType: PriceShowTypeEnum,
    minPrice: number,
    maxPrice: number,
    label?: string
) => {
    if (priceShowType === PriceShowTypeEnum.Free && minPrice === 0 && maxPrice === 0) {
        return {
            price: '免费',
            label
        };
    } else if (priceShowType === PriceShowTypeEnum.Negotiable && minPrice === 0 && maxPrice === 0) {
        return {
            price: '面议',
            label
        };
    } else {
        if (minPrice !== maxPrice) {
            return {
                price: `${formatToFixed(minPrice || 0)}~${formatToFixed(maxPrice || 0)}`,
                unit: '￥',
                label
            };
        }
        return { price: formatToFixed(minPrice || 0), unit: '￥', label };
    }
};